<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8" />
		<title>Document</title>
	</head>
	<body>
		<script type="text/javascript" >

			let data = {
				name:'hhh',
				address:'北京',
			}
			const obs=new observer(data)
			let vm={}
			vm._data=data=obs
			function observer(obj){
				const key=Object.keys(obj)
				key.forEach((k)=>{
					//data.name
					Object.defineProperty(this,k,{
						get(){
							return obj[k]
						},
						set(val){
							console.log(`${k}被修改了`)
							obj[k]=val
						}
					})

				})
			}

		</script>
	</body>
</html>